import os,time,random,datetime,keyboard
from  tkinter  import  *
from  tkinter  import filedialog,messagebox
def savefile():
    a = filedialog.asksaveasfilename()
    if a:
        open(a,"w").write(in_t.get())
    else:
        messagebox.showinfo("","用户取消保存！")
def openfile():
    a = filedialog.askopenfilename()
    in_t.delete(1,END)
    in_t.insert(1,chars=open(a,"r").read())
windows = Tk()
windows.iconphoto(0,PhotoImage(file="icon.png"))
windows.geometry("800x600")
windows.configure(bg="white")
windows.title("SmallText")
fn = ("Cascadia Mono",12)
in_t = Text(windows)
in_t.configure(bg="white",font=fn)
in_t.pack(ipadx=windows.winfo_width(),ipady=windows.winfo_height())
save = Button(text="Save As",command=savefile)
save.place(x=700,y=20)
opens = Button(text="Open", command=openfile)
opens.place(x=700, y=80)
windows.mainloop()